#include <iostream>
#include <string>
#include "IncidentLogDatabase.h"


int main1(int argc, char* argv[])
{
    std::string strUrl = "/clientlog/procincident";
    std::string strLog = "{\"HostGuid\":\"9801a7ed-9458-0000-0000-000000000000\",\"HostName\":\"synideMac - mini.local\"}";

    bool bRet = IncidentLogDatabase::GetInstance()->Initialize("IncDatabase.db");
    if (!bRet)
    {
        std::cout << "IncidentLogDatabase::GetInstance()->Initialize failed" << std::endl;
        return -1;
    }

    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    strUrl += "1";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }


    strUrl += "2";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    strUrl += "3";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    IncidentLogDatabase::GetInstance()->GetData(strUrl);

    strUrl = "/clientlog/procincident";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    IncidentLogDatabase::GetInstance()->CountByUrl(strUrl);


    IncidentLogDatabase::GetInstance()->GetTopData(strUrl, 2);


    IncidentLogDatabase::GetInstance()->UpdateTopData(strUrl, 2);

   // IncidentLogDatabase::GetInstance()->DeleteData(1);

    
//     strUrl = "/clientlog/procincident1";
//     if (!IncidentLogDatabase::GetInstance()->DeleteData(strUrl))
//     {
//         std::cout << "IncidentLogDatabase::GetInstance()->DeleteData" << std::endl;
//     }

    strUrl = "/clientlog/procincident";
    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }

    if (!IncidentLogDatabase::GetInstance()->AddIncidentLog(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->AddIncidentLog" << std::endl;
        return -1;
    }


    //IncidentLogDatabase::GetInstance()->GetData(strUrl);


   // IncidentLogDatabase::GetInstance()->ClearDataBase();
    
    return 0;
}


int main(int argc, char* argv[])
{
    std::string strUrl = "/clientlog/procincident";
    std::string strLog = "{\"HostGuid\":\"9801a7ed-9458-0000-0000-000000000000\",\"HostName\":\"synideMac - mini.local\"}";

    bool bRet = IncidentLogDatabase::GetInstance()->DatabaseInitial("New.db");
    if (!bRet)
    {
        std::cout << "IncidentLogDatabase::GetInstance()->DatabaseInitial failed" << std::endl;
        return -1;
    }

    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }

    strUrl += "1";
    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }


    strUrl += "2";
    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }

    strUrl += "3";
    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }

    strUrl = "/clientlog/procincident";
    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }

    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }

    IncidentLogDatabase::GetInstance()->CountByUrlNewAPI(strUrl);

    std::vector<std::string> vec;
    IncidentLogDatabase::GetInstance()->GetTopDataByUrl(strUrl, 2, vec);


    IncidentLogDatabase::GetInstance()->UpdateTopDataByUrl(strUrl, 2);

    IncidentLogDatabase::GetInstance()->DeleteDataByFlag(1);


    strUrl = "/clientlog/procincident1";
    if (!IncidentLogDatabase::GetInstance()->DeteleDataByUrl(strUrl))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->DeleteData" << std::endl;
    }

    strUrl = "/clientlog/procincident";
    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }

    if (!IncidentLogDatabase::GetInstance()->InsertData(strUrl, strLog))
    {
        std::cout << "IncidentLogDatabase::GetInstance()->InsertData" << std::endl;
        return -1;
    }

    IncidentLogDatabase::GetInstance()->GetDataByUrl(strUrl, vec);
    IncidentLogDatabase::GetInstance()->GetTopDataByUrl(strUrl, 2, vec);

    IncidentLogDatabase::GetInstance()->ClearDataBaseNewAPI();

    return 0;
}